package framework.util.codeset.vo;

import com.google.common.collect.BiMap;
import com.google.common.collect.HashBiMap;
import framework.util.codeset.bo.SysCodesetDetail;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * <b>缓存代码集，使用时注意NPE，如果获取不存在的代码集，将会返回null。</b><br/><br/>
 *
 * 使用示例： <br/>
 * System.out.println(BaseController.CODE.get("sex").getValue()); //输出性别 <br/>
 * System.out.println(BaseController.CODE.get("性别").getValue()); //输出sex <br/>
 *
 * System.out.println(BaseController.CODE.get("sex").get("1")); //输出男 <br/>
 * System.out.println(BaseController.CODE.get("sex").get("男")); //输出1 <br/>
 * System.out.println(BaseController.CODE.get("性别").get("1")); //输出男 <br/>
 * System.out.println(BaseController.CODE.get("性别").get("男")); //输出1 <br/>
 *
 * System.out.println(BaseController.CODE.get("sex").get("2")); //输出女 <br/>
 * System.out.println(BaseController.CODE.get("sex").get("女")); //输出2 <br/>
 * System.out.println(BaseController.CODE.get("性别").get("2")); //输出女 <br/>
 * System.out.println(BaseController.CODE.get("性别").get("女")); //输出2 <br/>
 *
 * @author 吴宇亮 on 2019/5/31 0031 下午 2:02
 */
public class CodesetVo {
    /** codeset的主键 **/
    private Integer lid;
    /** 即可能是codeset的key，也可能是value **/
    private String value;
    /** 存储该codeset对应的codesetDetailList **/
    private List<SysCodesetDetail> detailList;
    /** 存储该codeset对应的codesetDetail的键值对 **/
    private Map<String, String> detailMap;

    public CodesetVo(Integer lid, String value, List<SysCodesetDetail> detailList, Map<String, String> detailMap) {
        this.lid = lid;
        this.value = value;
        this.detailList = detailList;
        this.detailMap = detailMap;
    }

    public String get(String keyOrValue){
        return detailMap.get(keyOrValue);
    }

    public Integer getLid() {
        return lid;
    }

    public String getValue() {
        return value;
    }

    public String getEnName() {
        return value;
    }

    public String getCnName() {
        return value;
    }

    public List<SysCodesetDetail> getDetailList() {
        return detailList;
    }

    public Map<String, String> getDetailMap() {
        return detailMap;
    }

    @Override
    public String toString(){
        return value;
    }

}
